package com.example.yiqiuser.controller;


import com.example.yiqiuser.entity.Contact;
import com.example.yiqiuser.service.IContactService;
import com.example.yiqiuser.util.Page;
import com.example.yiqiuser.util.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * @ fileName:PtFcontactController
 * @ description:
 * @ createTime:2023/3/31 14:15
 * @ version:1.0.0
 * @author 诸葛龙辰
 */
@RestController
@RequestMapping("contact")
public class IContactController extends BaseController {
    @Resource
    private IContactService contactService;

    @GetMapping("queryByUserId")
    public Result queryByUserId(String userId) {
        return success(contactService.queryByUserId(userId));
    }

    @PostMapping("queryPage")
    public Result queryPage(@RequestBody Page<Contact> page) {
        return success(contactService.queryPage(page));
    }

    @GetMapping("queryById")
    public Result queryById(Integer id) {
        return success(contactService.queryById(id));
    }

    @PostMapping("addContact")
    public Result addContact(@RequestBody Contact contact) {
        return success(contactService.addContact(contact));
    }

    @PostMapping("updateContact")
    public Result updateContact(@RequestBody Contact contact) {
        return success(contactService.updateContact(contact));
    }

    @DeleteMapping("deleteById")
    public Result deleteById(Integer id) {
        return success(contactService.deleteById(id));
    }
}
